package com.googlecode.tracey.ui.core;

import com.googlecode.totallylazy.Callable1;
import com.googlecode.totallylazy.Pair;

import java.util.Map;

import static com.googlecode.totallylazy.Callables.returns;

public class Extension extends Pair<String,String> {

    private Extension(String id, String url) {
        super(returns(id), returns(url));
    }

    public static Extension extension(String id, String url) {
        return new Extension(id, url);
    }

    public String getId() {
        return first();
    }

    public String getUrl() {
        return second();
    }

    public static Callable1<Map<String, Object>, Extension> fromMap() {
        return new Callable1<Map<String, Object>, Extension>() {
            @Override
            public Extension call(Map<String, Object> map) throws Exception {
                return extension(map.get("id").toString(), map.get("url").toString());
            }
        };
    }
}
